unit i_logable;

interface

procedure addtolog(s:string);
procedure updateStatus(s:string);
var
 insertlog:boolean;

implementation

uses hstruct, sysutils, mhu_dall;

procedure addToComboLog(s:string);
begin;
 mh_dall.log.Items.add(s);
 mh_dall.log.ItemIndex:=mh_dall.log.Items.count-1;
// mh_dall.log.items.itemindex:=0;
end;

procedure updateStatus(s:string);
begin
 mh_dall.status.panels.items[0].text:=s;
end;


procedure addtolog(s:string);
var
 f:system.text;
 ws: string;
begin
 ws := s;
 assignfile(f,hostdir+'log.txt');
 if not fileexists(hostdir+'log.txt') then rewrite(f) else append(f);
 s:=datetostr(now)+'/'+timetostr(now)+' : '+s;
 if (insertlog = true) then addtocombolog(s);
 writeln(f,s);
 closefile(f);

 if (ws[1] = '#') then begin
  assignfile(f,hostdir+'error_log.txt');
  if not fileexists(hostdir+'error_log.txt') then rewrite(f) else append(f);
  writeln(f,s);
  closefile(f);
 end;
end;



end.
